package com.wzdigit.wms.wms.controller.common;

import com.wzdigit.framework.RandomlyThrowsException;
import com.wzdigit.framework.exception.RestStatusException;
import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.basic.enums.BaseIsEnabledEnum;
import com.wzdigit.wms.basic.enums.PrintFlagEnum;
import com.wzdigit.wms.basic.enums.SealFlagEnum;
import com.wzdigit.wms.basic.enums.task.TaskTypeEnum;
import com.wzdigit.wms.wms.constant.WmsWareConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Slf4j
@RestController
@Api(tags = "基础枚举控制层")
@RequestMapping(value = WmsWareConstant.API_VERSION)
public class BaseEnumController {
	
    public static final String REQUSET_MODEL = "/sys/common/baseenum";

    @RandomlyThrowsException
    @ApiOperation(value = "定时调度任务类型", notes = "定时调度任务类型")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getTaskTypeEnum")
    public Map<Integer, String> getTaskTypeEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return TaskTypeEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "启用状态", notes = "启用状态")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getBaseIsEnabledEnum")
    public Map<Integer, String> getBaseIsEnabledEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return BaseIsEnabledEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "打印标识", notes = "打印标识")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getPrintFlagEnum")
    public Map<Integer, String> getPrintFlagEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return PrintFlagEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "封库或者解封标识", notes = "封库或者解封标识")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getSealFlagEnum")
    public Map<Integer, String> getSealFlagEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return SealFlagEnum.getEnumByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
}
